<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="/template/template-padrao.xhtml">

	<ui:define name="titulo">Manter contas</ui:define>

	<ui:define name="baseCorpo">

		<h:form id="cadastroContaForm">
		
			<script type="text/javascript">
				jQuery(function(){
					jQuery('input[id*=banco]').focus();
				});
			</script>

			<h1 class="titulo-tela">Manter contas</h1>

			<p:panel id="panelCadastrarConta">

				<h1 class="ui-panel-titlebar ui-widget-header ui-corner-all">Dados cadastrais</h1>

				<h:panelGrid columns="3" cellspacing="10">
					<h:column>
						<h:outputLabel for="nomeBanco" value="* Banco:" />
						<br />
						<p:inputText id="banco" value="#{manterContasBean.conta.nmBanco}"
							label="Banco" />

					</h:column>
					
					<h:column>
						<h:outputLabel for="agencia" value="* Agência:" />
						<br />
						<p:inputText id="agencia" value="#{manterContasBean.conta.nrAgencia}"
							label="Agencia" />

					</h:column>
					
					<h:column>
						<h:outputLabel for="conta" value="* Conta:" />
						<br />
						<p:inputText id="conta" value="#{manterContasBean.conta.nrConta}"
							label="Conta" />

					</h:column>

				</h:panelGrid>
				
				<h:panelGrid columns="2" cellspacing="10">
					<h:column>
						<h:outputLabel for="nomeGerente" value="Gerente:" />
						<br />
						<p:inputText id="gerente" value="#{manterContasBean.conta.nmGerente}"
							label="Gerente" />

					</h:column>
					
					<h:column>
						<h:outputLabel for="telefone" value="Telefone:" />
						<br />
						<p:inputMask id="telefone" value="#{manterContasBean.conta.telefone}"
							label="telefone" mask="(99) 9999-9999" />
					</h:column>
					
					
				</h:panelGrid>

				<br />

			</p:panel>

			<br />
			<div align="right"><p:commandButton id="btn" value="Salvar"
				update="msgSistema, cadastroContaForm, listaConta"
				actionListener="#{manterContasBean.salvarConta}"
				style="margin-left:5px;" /> <p:commandButton id="botaoLimpar"
				value="Limpar"
				update="msgSistema, cadastroContaForm, listaConta"
				actionListener="#{manterContasBean.limparCampos}"
				style="margin-left:5px;" /></div>

		</h:form>

		<h:form id="listaConta">

			<br />
			<br />
			
			<p:accordionPanel autoHeight="false" collapsible="true" style="padding:0;">
			<p:tab title="Contas">
			
			<p:dataTable id="listaCadastroConta" var="conta"
				paginator="true" rows="10" paginatorPosition="bottom"
				value="#{manterContasBean.todosConta}"
				emptyMessage="Nenhum cadastro de conta encontrado">

				<p:column filterBy="#{conta.nmBanco}"
					headerText="Banco" filterMatchMode="contains">
					<h:outputText value="#{conta.nmBanco}" />

				</p:column>
				
				<p:column filterBy="#{conta.nrAgencia}"
					headerText="Agência" filterMatchMode="contains">
					<h:outputText value="#{conta.nrAgencia}" />

				</p:column>
				
				<p:column filterBy="#{conta.nrConta}"
					headerText="Conta" filterMatchMode="contains">
					<h:outputText value="#{conta.nrConta}" />

				</p:column>
				
				<p:column filterBy="#{conta.nmGerente}"
					headerText="Gerente" filterMatchMode="contains">
					<h:outputText value="#{conta.nmGerente}" />

				</p:column>
				
				<p:column filterBy="#{conta.telefone}"
					headerText="Telefone" filterMatchMode="contains">
					<h:outputText value="#{conta.telefone}" />

				</p:column>

				<p:column style="width:100px;" headerText="Ações">
					<p:commandButton update="cadastroContaForm"
						image="ui-icon ui-icon-pencil" immediate="true">
						<f:setPropertyActionListener value="#{conta}"
							target="#{manterContasBean.conta}" />

					</p:commandButton>
					<p:commandButton oncomplete="confirmation.show()"
						image="ui-icon ui-icon-trash" immediate="true">
						<f:setPropertyActionListener value="#{conta}"
							target="#{manterContasBean.conta}" />
					</p:commandButton>
				</p:column>

			</p:dataTable>
			
			</p:tab>
			</p:accordionPanel>

		</h:form>

		<h:form>
			<p:confirmDialog message="Deseja excluir o registro?"
				header="Confirmação" severity="alert" widgetVar="confirmation">

				<p:commandButton value="Sim"
					update="cadastroContaForm, msgSistema, listaConta"
					oncomplete="confirmation.hide()" immediate="true"
					actionListener="#{manterContasBean.excluirConta}" />
				<p:commandButton value="Não" onclick="confirmation.hide()"
					type="button" immediate="true" />

			</p:confirmDialog>
		</h:form>

	</ui:define>

</ui:composition>
</html>